<link href="${rc.getContextPath()}/manage/styles/treeGrid/stylesheets/jquery.treetable.css" media="all" rel="stylesheet" type="text/css" />
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">

<div class="pageContent" style="border-top: 1px solid #D9DFE5;" id="bomReversedListGrid"></div>

<script>
(function($){
	var $page = DWZ.context(), $grid = $('#bomReversedListGrid', $page),
	getFlagText = function(flag) {
		if (flag == 1) {
			return '√';
		} else {
			return '';
		}
	};
	$grid.jTreeGrid({
		layoutH: 73,
        base: '${rc.getContextPath()}/manage/bom/',
        url: 'reversedList',
        autoLoad: false,
        columns: [
            {field: 'componentCode', text: '<@label key="bomComponentCode.C">组件编号</@label>', width: 200, tdrender: function($td, data) {
            	var $icon = $('span', $td).detach();
            	$td.empty().append($icon).append($('<a class="link" />').text(data.componentCode).on('click', function(event){
            		var ops = {
            			data: {id: data.componentCode, navTabId: 'MATERIAL'},
            			mask: true,
            			width: 635,
            			height: 500
            		};
            		$.pdialog.open(hostUrl + '/material/viewMaterial', 'MATERIAL', '<@label key="viewMaterial.C">物料详情</@label>', ops);
            		return false;
            	}));
            }},
            {field: 'componentText', text: '<@label key="bomComponentText.C">组件描述</@label>', width: 200},
            {field: 'materialTypeText', text: '<@label key="materialTypeText.C">物料类型描述</@label>', width: 200},
            {field: 'makeFlag', text: '<@label key="makeFlag.C">自购件</@label>', width: 100, tdrender: function($td, data) {
        		$td.text(getFlagText(data.makeFlag));
        	}},
            {field: 'buyFlag', text: '<@label key="buyFlag.C">采购件</@label>', width: 100, tdrender: function($td, data) {
				$td.text(getFlagText(data.buyFlag));
        	}}
        ],
        query: {
			queryfields: [
				{field: 'materialCode', required: true, text: '<@label key="materialCode.C">物料编号</@label>', render: function($input) {
					$input.attr({
						name: "materialCode",
						lookupGroup: "positiveSearch",
						id: "positiveSearch.materialCode",
						postField: "materialCode",
						suggestFields: "materialCode,materialText",
						suggestUrl: "${rc.getContextPath()}/manage/material/componentSuggest",
						remote: "${rc.getContextPath()}/manage/material/validateMaterial",
						warn: "<@label key='materialCode.C,doesNotExist.C'>物料编号不存在</@label>"
					}).addClass('toUp');
				}},
				{field: 'materialText', text: '<@label key="materialText.C">物料描述</@label>', render: function($input) {
					$input.attr({
						lookupGroup: "positiveSearch",
						id: "positiveSearch.materialText",
						readonly: true
					});
				}}
			],
		},
		childrenField: 'childComponents'
	});
})(jQuery);
</script>